package com.salt.modules.log.config;


/**
 * @Description
 * @Author salt
 * @Date 2023/4/19
 * @Version 1.0.1
 */
//@Configuration
//@EqualsAndHashCode(callSuper = true)
//@EnableConfigurationProperties(ElasticsearchProps.class)
public class ElasticsearchConfig{

    /*@Resource
    private ElasticsearchProps esProps;*/
    //@Value("salt.elasticsearch.host")
    //private String host = "10.100.100.25";
    //@Value("salt.elasticsearch.port")
    //private int port = 9200;

    /*@Override
    public RestHighLevelClient elasticsearchClient() {
        return new RestHighLevelClient(RestClient.builder(new HttpHost(host, port)));
    }*/

    /*@Bean
    public ElasticsearchTemplate elasticsearchTemplate() {
        return new ElasticsearchTemplate();
    }*/

    /*@Value("${spring.elasticsearch.rest.host}")
    private String host;
    @Value("${spring.elasticsearch.rest.enable:true}")
    private boolean enable;

    @Value("${spring.elasticsearch.rest.port}")
    private int port;
    @Value("${spring.elasticsearch.rest.username}")
    private String userName;

    @Value("${spring.elasticsearch.rest.password}")
    private String passWord;*/

    /*@Bean
    public ElasticsearchClient elasticsearchClient() {
        *//*ElasticsearchClient client = new ElasticsearchClient(null);
        if (true){
            final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
            //设置账号密码
            *//**//*credentialsProvider.setCredentials(
                    AuthScope.ANY, new UsernamePasswordCredentials(userName, passWord));*//**//*

//        RestClients restClients =
            RestClient restClient = RestClient.builder(new HttpHost("127.0.0.1", 9200))
                    .setHttpClientConfigCallback(httpClientBuilder->httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)).build();

            ElasticsearchTransport transport = new RestClientTransport(restClient,new JacksonJsonpMapper());
            // And create the API client
            client = new ElasticsearchClient(transport);
        }*//*
        // 创建低级客户端
        RestClient restClient = RestClient.builder(
                new HttpHost("localhost", 9200)).build();

        // 使用Jackson映射器创建传输层
        ElasticsearchTransport transport = new RestClientTransport(
                restClient, new JacksonJsonpMapper());

        // 创建API客户端
        ElasticsearchClient client = new ElasticsearchClient(transport);
        return client;

    }*/
    /*@Bean
    public TransportClient getTransportClient() {
        TransportClient transportClient = null;
        try {
            Settings settings = Settings.builder()
                    .put("cluster.name","docker-cluster")
                    .put("client.transport.sniff",true)
                    .build();
            transportClient = new PreBuiltTransportClient(settings);
            TransportAddress firstAddress = new TransportAddress(InetAddress.getByName("192.168.0.101"),Integer.parseInt("9300"));
            transportClient.addTransportAddress(firstAddress);
        }catch (Exception e){
            e.printStackTrace();
            //logger.error("getTransportClient fail：" +  e.getMessage(),e);
        }
        return transportClient;
    }*/



}
